package com.cusc.lib_sdk_location_gd.mvvm.ui;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.cusc.lib_sdk_location_gd.BR;
import com.cusc.lib_sdk_location_gd.R;
import com.cusc.lib_sdk_location_gd.databinding.ActBaseMapBinding;
import com.cusc.lib_sdk_location_gd.factory.MapViewModuleFactory;
import com.cusc.lib_sdk_location_gd.mvvm.vm.GDMapBaseViewModel;
import com.tcgroup.phone.base_core.framework.mvvm.activity.ContainerMvvmActivity;

/**
 * 作者: wangfei
 * 创建时期: 2020/6/1.
 * 包名: com.cusc.lib_sdk_location_gd.activity
 * 类名: OSAndroidMvvm
 */
public class GDMapBaseMvvmActivity extends ContainerMvvmActivity<ActBaseMapBinding, GDMapBaseViewModel> {


    private MapView mMapView;
    private AMap mMap;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mMapView = mBinding.mapView;
        mMapView.onCreate(savedInstanceState);// 此方法必须重写
        mMap = mMapView.getMap();
    }

    @Override
    public int onBindVariableId() {
        return BR.model;
    }

    @Override
    public Class<GDMapBaseViewModel> onBindViewModel() {
        return GDMapBaseViewModel.class ;
    }

    @Override
    public ViewModelProvider.Factory onBindViewModelFactory() {
        return MapViewModuleFactory.getInstance(getApplication());
    }

    @Override
    public void initViewObservable() {

    }

    @Override
    public void onRetryBtnClick() {

    }

    @Override
    public void onBackPressedClick() {

    }

    @Override
    public int onBindLayout() {
        return R.layout.act_base_map;
    }

    @Override
    public Object bindLoadSir() {
        return this;
    }

    @Override
    protected void onResume() {
        super.onResume();
        mMapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mMapView.onPause();
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mMapView.onSaveInstanceState(outState);
    }

    /**
     * 方法必须重写
     */
    @Override
    protected void onDestroy() {
        super.onDestroy();
        mMapView.onDestroy();
    }

    public MapView getmMapView() {
        return mMapView;
    }

    public AMap getmMap() {
        return mMap;
    }
}
